package com.uaijug.dengue.dao;

import javax.persistence.EntityManager;

public class BaseDao {

	private EntityManager em;

	public BaseDao(EntityManager em) {
		this.em = em;
	}

	public Object save(Class<?> classe, Object obj) {
		try {
			em.persist(obj);
			return select(classe, obj);
		} catch (Exception e) {
			return null;
		}
	}

	public Object select(Class<?> classe, Long id) {
		try {
			return em.find(classe, id);
		} catch (Exception e) {
			return null;
		}
	}
	
	public Object select(Class<?> classe, Object obj) {
		try {
			return em.find(classe, obj);
		} catch (Exception e) {
			return null;
		}
	}

}
